<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script src="http://cdn.bootcss.com/jquery/2.2.4/jquery.js"></script>
<link rel="stylesheet" href="css/lyb.css">
<style type="text/css">
#box1 {
 margin: 0 auto;
 text-align: center;
 
 }
 </style>
</head>
<body>
<%@ include file="header.jsp" %>
	<!-- 发布留言的主体 -->
	<c:if test="${user!=null }">
	<form action="addquestion" method="post">
	<div class="wrap">
		<div class="wrap-head">
			<div class="head-logo">
				<img src="img/4.png" />
			</div>
			<div class="head-txt">
				<a class="title-txt" href="javascript:void(0)">TravelTime , Let  you  have  a  good  time  !</a>
			</div>
		</div>
		
		<div class="main-txt">
			<textarea name="message" rows="" cols="" class="main-area"></textarea>
		</div>
		
		<div class="warp-footer">
			<div class="warp-icon-cont">
				<ul>
					<li><img src="img/3.png" alt="" />
						<a href="javascript:void(0)">表情</a>
					</li>
					<li><img src="img/1.png" alt="" />
						<a href="javascript:void(0)">图片</a>
					</li>
					<li><img src="img/2.png" alt="" />
						<a href="javascript:void(0)">视频</a>
					</li>
				</ul>
			</div>
			<div class="warp-footer-btns">
				<div class="release-btn">
					<input type="submit" value="提交">
				</div>
			</div>
		</div>
	</div></form></c:if>
	<!-- 显示留言的主体 -->
	<c:if test="${findAllQuestion!=null}">
	<div id="box1">
	<ul>
	<c:forEach items="${findAllQuestion}" var="q">
    <li>
        ${q.user.username }评论
        <div>${q.message }  ${q.date}<br>
        <c:forEach items="${q.replys }" var="r">
        ${r.user.username }回复了${q.user.username }:${r.message }  ${r.date }<br>
        </c:forEach>
        
        <div class='reply_textarea${q.id }' style="display:none;">
	        <form action='addreply' method='post' >
		        <textarea name='message' cols='40' rows='5'></textarea>
		        <br/>
		        <input type="hidden" name="qid" value="${q.id }">
		        <input type='submit' value='发表' />
	        </form>
        </div>
        
        <a class="reply_btn" id="reply_btn${q.id }">回复</a></div>
        
    </li></c:forEach>
</ul>
</div>
</c:if>
 <script type="text/javascript">

		$(function() {
			//页面加载完毕后开始执行的事件
			var length = $(".reply_btn").length;
			console.log(length);
			for (var i = 1; i <= length; i++) {
				$("#reply_btn" + i).bind("click", {
					index : i
				}, clickHandler);
			}

			function clickHandler(event) {
				var i = event.data.index;
				$(".reply_textarea" + i).show();
			}
		});
		
	</script>
</body>
</html>